package com.cyandpos.pad.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.cyandpos.pad.R;
import com.cyandpos.pad.common.commondata.Constant;
import com.cyandpos.pad.common.commondata.ErpCommonData;
import com.cyandpos.pad.common.commondata.SktConfigIdCrmConstant;
import com.cyandpos.pad.common.swipemanager.SwipeCardCommon;
import com.cyandpos.pad.pay.adapter.PayCashCardListAdapter;
import com.cyandpos.pad.pay.presenter.PayCashCardPresenter;
import com.cyandpos.pad.pay.view.IPayCardCashView;
import com.cyandpos.pad.posdata.CashCardItem;
import com.cyandpos.pad.posdata.GetValueCardResponse;
import com.cyandpos.pad.posdata.Payment;
import com.cyandpos.pad.posdata.TicketInfo;
import com.cyandpos.pad.sale.view.SelfNumKeyView;
import com.cyandpos.pad.utils.CommonUtils;
import com.cyandpos.pad.utils.MoneyUtils;
import com.cyandpos.pad.utils.PayUtil;
import com.cyandpos.pad.utils.ToastUtils;
import com.cyandpos.pad.utils.log.MessageLog;
import com.cyandpos.pad.utils.log.LogUtils;
import com.cyandpos.pad.utils.view.InputNumberDialogCommon;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/5/9.
 */

public class PayCashCardActivity extends BaseActivity implements View.OnClickListener, AdapterView.OnItemClickListener, IPayCardCashView , SwipeCardCommon.DoAfterSwipeCard{
    @BindView(R.id.rl_close)
    RelativeLayout rl_close;
    @BindView(R.id.iv_act_paycashcard_swipe)
    ImageView swipeCardAgain;
    @BindView(R.id.et_act_paycashcard_money)
    EditText etInputMoney;
    @BindView(R.id.lv_act_paycashcard_payList)
    ListView lvCardList;
    @BindView(R.id.tv_act_paycashcard_balance)
    TextView tvBalance;
    @BindView(R.id.tv_act_paycashcard_cardcode)
    TextView tvCardCode;
    @BindView(R.id.tv_act_paycashcard_swpiestatus)
    TextView tvSwipeStatus;
    @BindView(R.id.btn_act_paycashcard_complete)
    Button btnComplete;
    @BindView(R.id.member_soft_keyboard)
    SelfNumKeyView sf_containt;
    private GetValueCardResponse currentCashCard = null;//当前刷储值卡
    private CashCardItem currentHadSwipeCashCard;
    public PayCashCardPresenter mPresenter;
    private ProgressDialog dialog;
    private TicketInfo mTicket;
    private PayCashCardListAdapter adapter;
    private boolean swiping = false;
    private int payType;
    private int paymentId = -1;
    private int positon=-1;
    private AlertDialog mDialog;//会员识别弹dialog
    private List<CashCardItem> usedCashCardList;//临时使用储值卡列表
    private Handler hander = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 0x00:
                    String cardNo = (String) msg.obj;
                    LogUtils.e("PayCashCard", cardNo);
                    List<CashCardItem> cashCardItemList = usedCashCardList;
                    Iterator it = cashCardItemList.iterator();
                    while (it.hasNext()) {
                        CashCardItem item = (CashCardItem) it.next();
                        if (item.getCardNo().equals(cardNo)) {
                            it.remove();
                        }
                    }
                    adapter.notifyDataSetChanged();
                    break;
                default:
                    break;

            }
        }
    };

    @Override
    protected int getLayoutId() {
        return R.layout.activity_paycashcard;
    }

    @Override
    protected void initData() {
        initView();
        mTicket = ErpCommonData.ticketInfo;
        if (mTicket.getCashCardList().size() > 0) {
            usedCashCardList.addAll(mTicket.getCashCardList());
            positon=usedCashCardList.size()-1;
            mTicket.getCashCardList().clear();
            LogUtils.e("USE_LIST","当前储值卡列表长度为："+usedCashCardList.size());
            CashCardItem okItem = usedCashCardList.get(usedCashCardList.size()-1);
            if (okItem != null) {
                currentHadSwipeCashCard = okItem;
                tvCardCode.setText(currentHadSwipeCashCard.getCardNo() + "");
                tvBalance.setText(MoneyUtils.getMoneyStr(currentHadSwipeCashCard.getmLeft() + currentHadSwipeCashCard.getmMoney()) + "");
            }
    //        PayUtil.showSoftKeyboard(etInputMoney,PayCashCardActivity.this);
        }else {
            PayUtil.showQueryMemberDialog(PayCashCardActivity.this,Constant.MEMBER_IDENTIFYING_CASHCARD);
        }
        adapter = new PayCashCardListAdapter(PayCashCardActivity.this, usedCashCardList, hander);
        adapter.setIndex(positon);
        lvCardList.setAdapter(adapter);

    }

    public void initView() {
        mPresenter = new PayCashCardPresenter(this);
        dialog = new ProgressDialog(PayCashCardActivity.this);
        dialog.setCancelable(false);
        dialog.setMessage("loading ....");
        usedCashCardList =new ArrayList<>();

        Bundle bundle = getIntent().getExtras();
        paymentId = bundle.getInt("PAYMENTID");
        payType=bundle.getInt("PAYTYPE");
        swipeCardAgain.setOnClickListener(this);
        lvCardList.setOnItemClickListener(this);
        btnComplete.setOnClickListener(this);
        rl_close.setOnClickListener(this);
     //   etInputMoney.setOnEditorActionListener(new MyOnEditListener());
        tvCardCode.setText("");
        tvBalance.setText("      ");
       // etInputMoney.setFocusable(false);
        CommonUtils.setNoSoftware(etInputMoney, PayCashCardActivity.this, true);
        sf_containt.setIsCanInputPoint(true);
        sf_containt.setEnterReceptor(etInputMoney);
        sf_containt.setIsClearEt(true);
        sf_containt.setOnCallBack(new SelfNumKeyView.SelfNumCallBack() {
            @Override
            public void keyBoardSure(String num,String hint) {
                try{
                    int currentPay = MoneyUtils.getMoneyInt(etInputMoney.getText().toString());
                    if (currentPay <= 0) {
                        ToastUtils.showMsg("请正确输入金额");
                    }else {
                        if(currentCashCard != null && swiping){
                            if(PayUtil.isReturnedTrade(mTicket)){
                                int oldTradeMoney = getOldTradeCzkTotalMoney();
                                if(currentPay > oldTradeMoney){//
                                    ToastUtils.showMsg("退款金额大于原交易金额！");
                                }else{
                                    if(usedCashCardList.size()>0){
                                        boolean isExist = false;
                                        for(CashCardItem item :usedCashCardList){
                                            if( currentCashCard.getCardId() == item.getCardId()){
                                                isExist = true;
                                            }
                                        }
                                        if(isExist){
                                            Iterator<CashCardItem> iterator = usedCashCardList.iterator();
                                            while (iterator.hasNext()) {
                                                CashCardItem item = iterator.next();
                                                if(currentCashCard.getCardId() == item.getCardId()){
                                                    iterator.remove();
                                                }
                                            }
                                            initUsedCashCardList(currentPay);
                                        }else{
                                            initUsedCashCardList(currentPay);
                                        }
                                    }else{
                                        initUsedCashCardList(currentPay);
                                    }
                                    etInputMoney.setText("");
                                }

                            }else{
                                int leftNeedPay = mTicket.getTotalMoney() - mTicket.getHasPayed();
                                int maxNeedPay = Math.min(leftNeedPay, MoneyUtils.getMoneyInt(currentCashCard.getBalance()+""));
                                if (maxNeedPay < currentPay) {
                                    ToastUtils.showMsg("该卡最大允许使用金额:" + MoneyUtils.getMoneyStr(maxNeedPay));
                                }else{
                                    if(usedCashCardList.size()>0){
                                        boolean isExist = false;
                                        for(CashCardItem item :usedCashCardList){
                                            if(currentCashCard.getCardId() == item.getCardId()){
                                                isExist = true;
                                            }
                                        }
                                        if(isExist){
                                            Iterator<CashCardItem> iterator = usedCashCardList.iterator();
                                            while (iterator.hasNext()) {
                                                CashCardItem item = iterator.next();
                                                if( currentCashCard.getCardId() == item.getCardId()){
                                                    iterator.remove();
                                                }
                                            }
                                            initUsedCashCardList(currentPay);
                                        }else{
                                            initUsedCashCardList(currentPay);
                                        }
                                    }else{
                                        initUsedCashCardList(currentPay);
                                    }
                                    etInputMoney.setText("");
                                }
                            }


                        }else{//没有刷储值卡按回车提示
                            if(usedCashCardList!=null&&usedCashCardList.size()>0){
                                usedCashCardList.get(positon).setmMoney(currentPay);
                                adapter.notifyDataSetChanged();
                            }else {
                                ToastUtils.showMsg("请先刷卡！");
                            }
                        }
                    }
                }catch (Exception e){
                    ToastUtils.show("请正确输入金额");
                    return;
                }

            }
        });
    }

    public void getCashCard(String conType, String conValue, String password, String verifiedCode) {
        mPresenter.getCashCard(conType, conValue, password, verifiedCode);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_close: {//回退按钮
                mTicket.setCashCardList(usedCashCardList);
                Intent intent = new Intent();
                setResult(Activity.RESULT_OK, intent);
                finish();
            }
            break;
            case R.id.iv_act_paycashcard_swipe://加号再次刷卡
                currentCashCard = null;
                tvCardCode.setText("");
                tvBalance.setText("      ");
               PayUtil.showQueryMemberDialog(PayCashCardActivity.this,Constant.MEMBER_IDENTIFYING_CASHCARD);
                break;
            case R.id.btn_act_paycashcard_complete://确定
                if(usedCashCardList!=null&&usedCashCardList.size()>0) {
                    mTicket.getCashCardList().clear();
                    mTicket.getCashCardList().addAll(usedCashCardList);
                    setResult(Activity.RESULT_OK, null);
                    finish();
                }else{
                    try{
                        int currentPay = MoneyUtils.getMoneyInt(etInputMoney.getText().toString());
                        if (currentPay <= 0) {
                            ToastUtils.showMsg("请正确输入金额");
                        }else {
                            if(currentCashCard != null && swiping){
                                if(PayUtil.isReturnedTrade(mTicket)){
                                    int oldTradeMoney = getOldTradeCzkTotalMoney();
                                    if(currentPay > oldTradeMoney){//
                                        ToastUtils.showMsg("退款金额大于原交易金额！");
                                    }else{
                                        if(usedCashCardList.size()>0){
                                            boolean isExist = false;
                                            for(CashCardItem item :usedCashCardList){
                                                if(currentCashCard.getCardId() == item.getCardId()){
                                                    isExist = true;
                                                }
                                            }
                                            if(isExist){
                                                Iterator<CashCardItem> iterator = usedCashCardList.iterator();
                                                while (iterator.hasNext()) {
                                                    CashCardItem item = iterator.next();
                                                    if(currentCashCard.getCardId() == item.getCardId()){
                                                        iterator.remove();
                                                    }
                                                }
                                                initUsedCashCardList(currentPay);
                                            }else{
                                                initUsedCashCardList(currentPay);
                                            }
                                        }else{
                                            initUsedCashCardList(currentPay);
                                        }
                                        etInputMoney.setText("");
                                    }

                                }else{
                                    int leftNeedPay = mTicket.getTotalMoney() - mTicket.getHasPayed();
                                    int maxNeedPay = Math.min(leftNeedPay, MoneyUtils.getMoneyInt(currentCashCard.getBalance()+""));
                                    if (maxNeedPay < currentPay) {
                                        ToastUtils.showMsg("该卡最大允许使用金额:" + MoneyUtils.getMoneyStr(maxNeedPay));
                                    }else{
                                        if(usedCashCardList.size()>0){
                                            boolean isExist = false;
                                            for(CashCardItem item :usedCashCardList){
                                                if(currentCashCard.getCardId() == item.getCardId()){
                                                    isExist = true;
                                                }
                                            }
                                            if(isExist){
                                                Iterator<CashCardItem> iterator = usedCashCardList.iterator();
                                                while (iterator.hasNext()) {
                                                    CashCardItem item = iterator.next();
                                                    if( currentCashCard.getCardId() == item.getCardId()){
                                                        iterator.remove();
                                                    }
                                                }
                                                initUsedCashCardList(currentPay);
                                            }else{
                                                initUsedCashCardList(currentPay);
                                            }
                                        }else{
                                            initUsedCashCardList(currentPay);
                                        }
                                        etInputMoney.setText("");
                                    }
                                }

                                mTicket.getCashCardList().clear();
                                mTicket.getCashCardList().addAll(usedCashCardList);
                                setResult(Activity.RESULT_OK, null);
                                finish();

                            }else{//没有刷储值卡按回车提示
                                ToastUtils.showMsg("请先刷卡！");
                            }
                        }
                    }catch (Exception e){
                        ToastUtils.show("请正确输入金额");
                        return;
                    }

                }
                break;
            default:
                break;
        }
    }

    /**
     * 储值卡查询成功(显示已刷卡信息)
     * @param cashCard
     */
    @Override
    public void showCashCardInfoOfSwipe(GetValueCardResponse cashCard) {
        currentCashCard = cashCard;
        swiping = true;
        tvSwipeStatus.setText("已刷卡");
        tvCardCode.setText(cashCard.getCardCode() + "");
        tvBalance.setText(cashCard.getBalance() + "");

        if(PayUtil.isReturnedTrade(mTicket)){
            int cardMoney=0;
            if(usedCashCardList!=null&&usedCashCardList.size()>0){
                for(int i=0;i<usedCashCardList.size();i++){
                    cardMoney+=usedCashCardList.get(i).getmMoney();
                }
            }
            int oldTradeTotal = getOldTradeCzkTotalMoney();
            if(oldTradeTotal-cardMoney>0){
                etInputMoney.setText(MoneyUtils.getMoneyStr(oldTradeTotal-cardMoney) + "");//金额自动带出
                etInputMoney.setSelection(etInputMoney.getText().length());
             //   PayUtil.showSoftKeyboard(etInputMoney,PayCashCardActivity.this);
            }else{
                ToastUtils.showMsg("原交易储值卡付款金额为零！");
            }
        }else{//消费
            int cardMoney=0;
            if(usedCashCardList!=null&&usedCashCardList.size()>0){
                for(int i=0;i<usedCashCardList.size();i++){
                    cardMoney+=usedCashCardList.get(i).getmMoney();
                }
            }
            int leftNeedPay = mTicket.getTotalMoney()- mTicket.getHasPayedDeleteCard()-cardMoney;
            int maxNeedPay = Math.min(leftNeedPay, MoneyUtils.getMoneyInt(cashCard.getBalance()+""));
            etInputMoney.setText(MoneyUtils.getMoneyStr(maxNeedPay) + "");//金额自动带出
            etInputMoney.setSelection(etInputMoney.getText().length());
 //           PayUtil.showSoftKeyboard(etInputMoney,PayCashCardActivity.this);
        }


    }

    private int getOldTradeCzkTotalMoney() {
        int oldTradeTotal =0;
        for(Payment p : ErpCommonData.oldTicket.getPayList()){
            if(p.getPayType() == Payment.SKFS_CZK){
                oldTradeTotal += MoneyUtils.getMoneyInt(p.getPayAmount());
            }
        }
        return oldTradeTotal;
    }

    @Override//监听软键盘的enter键
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getKeyCode() == event.KEYCODE_ENTER
                && KeyEvent.ACTION_UP == event.getAction()) {
            return false;
        }
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            return false;
        }
        if (event.getKeyCode() == KeyEvent.KEYCODE_HOME) {
            return false;
        }
        return super.dispatchKeyEvent(event);
    }

    @Override
    public void showProgress(String msg) {
        if (dialog.isShowing()) {
            dialog.setMessage(msg);
        } else {
            dialog.setMessage(msg);
            dialog.show();
        }
    }

    @Override
    public void dismissProgress() {
        if (dialog.isShowing()) {
            dialog.dismiss();
        }
    }

    @Override
    public void showLoadFailureMsg(String msg) {
        MessageLog.writeLog("loadFailure" + msg);
        ToastUtils.showMsg(msg);
    }

    /**
     * ListView的Item点击事件
     * @param parent
     * @param view
     * @param position
     * @param id
     */
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        //showClickCashCardUseMoneyDialog(position);
        this.positon=position;
        adapter.setIndex(positon);
    }

    private void showClickCashCardUseMoneyDialog(final int position) {
        CashCardItem item = usedCashCardList.get(position);
        AlertDialog.Builder dialog = new AlertDialog.Builder(PayCashCardActivity.this);
        View v = getLayoutInflater().inflate(R.layout.dialog_yhq_payactivity, null);
        dialog.setView(v);
        dialog.setTitle("请输入修改金额");
        dialog.setMessage("卡号："+ item.getCardNo());
        final EditText et = (EditText) v.findViewById(R.id.dialog_et);
        PayUtil.showSoftKeyboard(et,PayCashCardActivity.this);

        dialog.setPositiveButton("确定", new DialogInterface.OnClickListener(){

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                String modifyJe = et.getText().toString();
                MessageLog.writeLog("输入的储值卡修改的金额为："+modifyJe);
                if(TextUtils.isEmpty(modifyJe)){
                    ToastUtils.showMsg("请输入正确的金额！");
                }else{
                    usedCashCardList.get(position).setmMoney(MoneyUtils.getMoneyInt(modifyJe));
                    adapter.notifyDataSetChanged();
                }
            }});
        dialog.setNegativeButton("取消", null);
        dialog.setCancelable(false);
        dialog.show();

    }

    /**
     * 刷卡返回
     * @param isSuccess
     * @param result
     * @param handId
     */
    @Override
    public void doAfterSwipeCard(boolean isSuccess, String result, int handId) {
        switch (handId) {
            case Constant.CZK_SWIPECARD_HANDLEID: {
                if (isSuccess) {
                  //   result = "666666";
                    if(ErpCommonData.loadConfig.getSkt().getLength_verify_cashcard()>0){
                        showCashCardVerifiedCodeDialog(result,SktConfigIdCrmConstant.SKT_CONFIG_MEMBER_TYPE_SWIPE+"");//需要输入验证码
                    }else{
                        getCashCard(SktConfigIdCrmConstant.SKT_CONFIG_MEMBER_TYPE_SWIPE+"", result, "", "");
                    }
                } else {
                    ToastUtils.showMsg( result + ",请重试！");
                }
            }
            break;
            default:
                break;
        }
    }

    private void showCashCardVerifiedCodeDialog(final String conValue, final String conType) {
        InputNumberDialogCommon inputNumberDialogCommon= InputNumberDialogCommon.getInputNumberDialogCommon(PayCashCardActivity.this, new InputNumberDialogCommon.InputDialogOnSubmitClickListener() {
            @Override
            public void InputDialogOnSubmitClick(String content) {
                if(content.equals("") || content==null){
                    ToastUtils.showMsg( "请输入储值卡验证码");
                    return;
                }
                if(content.length() >0 && content.length()==ErpCommonData.loadConfig.getSkt().getLength_verify_cashcard()){
                    dialog.dismiss();
                    getCashCard(conType, conValue, "", content);//0001040470
                }else{
                    ToastUtils.showMsg( "输入验证码错误！");
                }
            }
        });
        inputNumberDialogCommon.setIsCanInputPoint(false);
        inputNumberDialogCommon.setTitle("储值卡验证码");
        inputNumberDialogCommon.setContent("请输入储值卡验证码");
        inputNumberDialogCommon.setEtHint("请输入储值卡验证码");
        inputNumberDialogCommon.showDialog(false);
    }

    /**
     * 输入金额回车事件监听
     */
    public class MyOnEditListener implements TextView.OnEditorActionListener {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (v.getId() == R.id.et_act_paycashcard_money) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    int currentPay = MoneyUtils.getMoneyInt(v.getText().toString());
                    if (currentPay <= 0) {
                        ToastUtils.showMsg("请正确输入金额");
                    }else {
                        if(currentCashCard != null && swiping){
                            if(PayUtil.isReturnedTrade(mTicket)){
                                 int oldTradeMoney = getOldTradeCzkTotalMoney();
                                 if(currentPay > oldTradeMoney){//
                                     ToastUtils.showMsg("退款金额大于原交易金额！");
                                 }else{
                                     if(usedCashCardList.size()>0){
                                         boolean isExist = false;
                                         for(CashCardItem item :usedCashCardList){
                                             if( currentCashCard.getCardId() == item.getCardId()){
                                                 isExist = true;
                                             }
                                         }
                                         if(isExist){
                                             Iterator<CashCardItem> iterator = usedCashCardList.iterator();
                                             while (iterator.hasNext()) {
                                                 CashCardItem item = iterator.next();
                                                 if(currentCashCard.getCardId() == item.getCardId()){
                                                     iterator.remove();
                                                 }
                                             }
                                             initUsedCashCardList(currentPay);
                                         }else{
                                             initUsedCashCardList(currentPay);
                                         }
                                     }else{
                                         initUsedCashCardList(currentPay);
                                     }
                                     etInputMoney.setText("");
                                 }

                            }else{
                                int leftNeedPay = mTicket.getTotalMoney() - mTicket.getHasPayed();
                                int maxNeedPay = Math.min(leftNeedPay, MoneyUtils.getMoneyInt(currentCashCard.getBalance()+""));
                                if (maxNeedPay < currentPay) {
                                    ToastUtils.showMsg("该卡最大允许使用金额:" + MoneyUtils.getMoneyStr(maxNeedPay));
                                }else{
                                    if(usedCashCardList.size()>0){
                                        boolean isExist = false;
                                        for(CashCardItem item :usedCashCardList){
                                            if( currentCashCard.getCardId() == item.getCardId()){
                                                isExist = true;
                                            }
                                        }
                                        if(isExist){
                                            Iterator<CashCardItem> iterator = usedCashCardList.iterator();
                                            while (iterator.hasNext()) {
                                                CashCardItem item = iterator.next();
                                                if(currentCashCard.getCardId() == item.getCardId()){
                                                    iterator.remove();
                                                }
                                            }
                                            initUsedCashCardList(currentPay);
                                        }else{
                                            initUsedCashCardList(currentPay);
                                        }
                                    }else{
                                        initUsedCashCardList(currentPay);
                                    }
                                    etInputMoney.setText("");
                                }
                            }


                        }else{//没有刷储值卡按回车提示
                            ToastUtils.showMsg("请先刷卡！");
                        }
                    }
                }
            }
            return false;
        }
    }

    private void initUsedCashCardList(int currentPay) {
        CashCardItem item = new CashCardItem();
        item.setCardId(currentCashCard.getCardId());
        item.setCardNo(currentCashCard.getCardCode());
        item.setmMoney(currentPay);
        if(PayUtil.isReturnedTrade(mTicket))
            item.setmLeft(MoneyUtils.getMoneyInt(currentCashCard.getBalance()+"") + currentPay);
        else
            item.setmLeft(MoneyUtils.getMoneyInt(currentCashCard.getBalance()+"")-currentPay);
        item.setBottom(MoneyUtils.getMoneyInt(currentCashCard.getBottom()+""));
        item.setPayCode(paymentId +"");
        item.setPayType(payType);
        usedCashCardList.add(item);
        positon=usedCashCardList.size()-1;
        adapter.setIndex(positon);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode != Activity.RESULT_OK)
            return;
        switch (requestCode){
            case Constant.CZK_SCAN_HANDLEID:  //储值卡扫码识别
                Bundle extras = data.getExtras();
                String content = extras.getString("Code");
                if (TextUtils.isEmpty(content))
                    return;
                if(ErpCommonData.loadConfig.getSkt().getLength_verify_cashcard()>0){
                    showCashCardVerifiedCodeDialog(content, SktConfigIdCrmConstant.SKT_CONFIG_MEMBER_TYPE_SCAN+"");//需要输入验证码
                }else{
                    getCashCard(SktConfigIdCrmConstant.SKT_CONFIG_MEMBER_TYPE_SCAN+"", content, "", "");
                }
                break;
            default:
                break;
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    public void QuickResult(String content ,String type){
        if(ErpCommonData.loadConfig.getSkt().getLength_verify_cashcard()>0){
            showCashCardVerifiedCodeDialog(content,type);//需要输入验证码
        }else{
            getCashCard(type, content, "", "");
        }
    }
}
